  <script type="text/javascript">
   <!--
    //Validar o utilizador
    function validaUsername(fld, error_field) 
    {
    	fld = document.getElementById(fld);
		var my_field=document.getElementById(error_field);
    	var illegalChars = /\W/; // alfanuméricos e underscore
    	erro = "";
 
    	if (fld.value == "") {
        	fld.style.background = '#FF9393';
        	my_field.style.background = '#FFFFAE';
    		my_field.style.display = '';
    		my_field.innerHTML = "<?=REGISTO_STEP1_ERRO_USER_VAZIO ?>";
    		erro = "<?=REGISTO_STEP1_ERRO_USER_VAZIO ?>";
    	} else if ((fld.value.length < 5) || (fld.value.length > 32)) {
        	fld.style.background = '#FF9393';
        	my_field.style.background = '#FFFFAE';
    		my_field.style.display = '';
    		my_field.innerHTML = "<?=REGISTO_STEP1_ERRO_USER_COMP ?>";
    		erro = "<?=REGISTO_STEP1_ERRO_USER_COMP ?>";
    	} else if (illegalChars.test(fld.value)) {
        	fld.style.background = '#FF9393'; 
        	my_field.style.background = '#FFFFAE';
    		my_field.style.display = '';
    		my_field.innerHTML = "<?=REGISTO_STEP1_ERRO_USER_ILE ?>";
    		erro = "<?=REGISTO_STEP1_ERRO_USER_ILE ?>";
    	} else {
        	fld.style.background = 'White';
    	}
    	return erro;
	}
	
	//Validar o campo primeiro nome, ultimo nome
    function validaPU(fld, error_field) 
    {
    	fld = document.getElementById(fld);
		var my_field=document.getElementById(error_field);
    	var illegalChars = /\W/; // alfanuméricos e underscore
    	erro = "";
 
    	if (fld.value == "") {
        	fld.style.background = '#FF9393';
        	my_field.style.background = '#FFFFAE';
    		my_field.style.display = '';
    		my_field.innerHTML = "<?=REGISTO_STEP1_ERRO_USER_VAZIO ?>";
    		erro = "<?=REGISTO_STEP1_ERRO_PASS_NUM ?>";
    	} else if ((fld.value.length < 5) || (fld.value.length > 32)) {
        	fld.style.background = '#FF9393';
        	my_field.style.background = '#FFFFAE';
    		my_field.style.display = '';
    		my_field.innerHTML = "<?=REGISTO_STEP1_ERRO_USER_COMP ?>";
    		erro = "<?=REGISTO_STEP1_ERRO_PASS_NUM ?>";
    	} else {
        	fld.style.background = 'White';
    	}
    	return erro;
	}
	
	function trim(s)
	{
  		return s.replace(/^\s+|\s+$/, '');
	}

	function validaEmail(fld, error_field) 
	{
		fld = document.getElementById(fld);
    	var my_field=document.getElementById(error_field);
    	var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    	var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    	var illegalChars= /[\#\$\'\(\)\<\>\,\;\:\\\"\[\]]/ ;
    	erro = "";
   
    	if (fld.value == "") {
        	fld.style.background = '#FF9393';
        	my_field.style.background = '#FFFFAE';
    		my_field.style.display = '';
    		my_field.innerHTML = "<?=REGISTO_STEP1_ERRO_EMAIL_VAZIO ?>";
    		erro = "<?=REGISTO_STEP1_ERRO_PASS_NUM ?>";
    	} else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        	fld.style.background = '#FF9393';
        	my_field.style.background = '#FFFFAE';
    		my_field.style.display = '';
    		my_field.innerHTML = "<?=REGISTO_STEP1_ERRO_EMAIL_INC ?>";
    		erro = "<?=REGISTO_STEP1_ERRO_PASS_NUM ?>";
    	} else if (fld.value.match(illegalChars)) {
        	fld.style.background = '#FF9393';
        	my_field.style.background = '#FFFFAE';
    		my_field.style.display = '';
    		my_field.innerHTML = "<?=REGISTO_STEP1_ERRO_EMAIL_ILE ?>";
    		erro = "<?=REGISTO_STEP1_ERRO_PASS_NUM ?>";
    	} else {
        	fld.style.background = 'White';
    	}
    	return erro;
	}
	
	//Validar o campo primeiro nome, ultimo nome
    function validaTelefone(fld, error_field) 
    {
    	fld = document.getElementById(fld);
		var my_field=document.getElementById(error_field);
    	var illegalChars = /\W/; // alfanuméricos e underscore
    	erro = "";
 
    	if (fld.value.length > 45) {
        	fld.style.background = '#FF9393';
        	my_field.style.background = '#FFFFAE';
    		my_field.style.display = '';
    		my_field.innerHTML = "<?=REGISTO_STEP1_ERRO_USER_COMP ?>";
    		erro = "<?=REGISTO_STEP1_ERRO_PASS_NUM ?>";
    	} else {
        	fld.style.background = 'White';
    	}
    	return erro;
	}
	
	function validaPassword(fld, error_field) 
	{
		fld = document.getElementById(fld);
    	var my_field=document.getElementById(error_field);
    	var illegalChars = /[\W_]/; // allow only letters and numbers 
    	erro = "";
 
    	if (fld.value == "") {
        	fld.style.background = '#FF9393';
        	my_field.style.background = '#FFFFAE';
    		my_field.style.display = '';
    		my_field.innerHTML = "<?=REGISTO_STEP1_ERRO_PASS_VAZ ?>";
    		erro = "<?=REGISTO_STEP1_ERRO_PASS_NUM ?>";
    	} else if ((fld.value.length < 6) || (fld.value.length > 20)) {
    		fld.style.background = '#FF9393';
        	my_field.style.background = '#FFFFAE';
    		my_field.style.display = '';
    		my_field.innerHTML = "<?=REGISTO_STEP1_ERRO_PASS_COMP ?>";
    		erro = "<?=REGISTO_STEP1_ERRO_PASS_NUM ?>";
    	} else if (illegalChars.test(fld.value)) {
    		fld.style.background = '#FF9393';
        	my_field.style.background = '#FFFFAE';
    		my_field.style.display = '';
    		my_field.innerHTML = "<?=REGISTO_STEP1_ERRO_PASS_ILE ?>";
    		erro = "<?=REGISTO_STEP1_ERRO_PASS_NUM ?>";
    	} else if (!(((((fld.value.match(/[^0-9]/)) && 1) * 1) * (fld.value.match(/\d+/)) * 1) && 1)) {
    		fld.style.background = '#FF9393';
        	my_field.style.background = '#FFFFAE';
    		my_field.style.display = '';
    		my_field.innerHTML = "<?=REGISTO_STEP1_ERRO_PASS_NUM ?>";
    		erro = "<?=REGISTO_STEP1_ERRO_PASS_NUM ?>";
    	} else {
        	fld.style.background = 'White';
		}
		return erro;
    }
    	
    function PasswordCompara(fld, error_field, pass) 
	{
		fld = document.getElementById(fld);
    	var my_field=document.getElementById(error_field);
    	var pass_field = document.getElementById(pass);
    	var illegalChars = /[\W_]/; // allow only letters and numbers 
    	erro = "";
 
    	if (fld.value != pass_field.value) {
        	fld.style.background = '#FF9393';
        	my_field.style.background = '#FFFFAE';
    		my_field.style.display = '';
    		my_field.innerHTML = "<?=REGISTO_STEP1_ERRO_PASS_CONF ?>";
    		erro = "<?=REGISTO_STEP1_ERRO_PASS_CONF ?>";
    	} else {
        	fld.style.background = 'White';       	
    	}
    	return erro;
	}
	
	//Validar o campo primeiro nome, ultimo nome
    function validaNIF(fld, error_field) 
    {
    	fld = document.getElementById(fld);
		var my_field=document.getElementById(error_field);
    	var illegalChars = /\W/; // alfanuméricos e underscore
    	erro = "";
 
    	if (fld.value == "") {
        	fld.style.background = '#FF9393';
        	my_field.style.background = '#FFFFAE';
    		my_field.style.display = '';
    		my_field.innerHTML = "<?=REGISTO_STEP1_ERRO_USER_VAZIO ?>";
    		erro = "<?=REGISTO_STEP1_ERRO_USER_VAZIO ?>";
    	} else if ((fld.value.length < 5) || (fld.value.length > 15)) {
        	fld.style.background = '#FF9393';
        	my_field.style.background = '#FFFFAE';
    		my_field.style.display = '';
    		my_field.innerHTML = "<?=REGISTO_STEP1_ERRO_USER_COMP ?>";
    		erro = "<?=REGISTO_STEP1_ERRO_USER_COMP ?>";
    	} else {
        	fld.style.background = 'White';
    	}
    	return erro;
	}
	
	function validaTodos() 
	{
		reason = validaUsername('utilizador', 'form_erro');
  		reason += validaPU('primeiro_nome', 'form_erro');
  		reason += validaPU('ultimo_nome', 'form_erro');
  		reason += validaEmail('email', 'form_erro');
  		reason += validaTelefone('contacto', 'form_erro');
  		reason += validaTelefone('fax', 'form_erro');
  		reason += validaPassword('pass', 'form_erro');
  		reason += PasswordCompara('check_pass', 'form_erro', 'pass');
  		reason += validaNIF('nif', 'form_erro') ;
  		
  		if (reason != "") {
    		return false;
  		}
  		return true;
  	}  
	//-->
  </script>
  <div id="fundo_cinza_cima">
  </div>
  <div id="fundo_cinza_wrapper">
   <div id="top_nav">
    <div class="cabecalho_registo">
     <div style="float: left;">
      <img src="/public/images/template/icon_utilizador.gif"></img>REGISTO UTILIZADOR
     </div>
     <div class="top_info_registo">
      <div style="font-size: 30px; margin-right: 10px; font-weight: bold; font-family: arial; color: #666666; float: left;">
       4
      </div>
      <div style="float: left; width: 150px;">
       <div style="font-size: 12px; font-weight: bold; font-family: arial; color: #666666;">
    	PASSOS
       </div>
       <div style="font-size: 11px; font-weight: bold; font-family: arial; color: #666666;">
    	para finalizar o registo
       </div>
      </div>
     </div>
    </div>
    <div class="barra_orientacao">
	 <ul class="passos">
	  <li><? if($passo_num == 1) { echo "<div class='p_selecionado'>1</div>"; } else { echo "<div class='p_uselecionado'>1</div>"; }?><div class='pt_texto'><?=REGISTO_LEFT_PASSO1?></div></li>
	  <li><? if($passo_num == 2) { echo "<div class='p_selecionado'>2</div>"; } else { echo "<div class='p_uselecionado'>2</div>"; }?><div class='pt_texto'><?=REGISTO_LEFT_PASSO2?></div></li>
	  <li><? if($passo_num == 3) { echo "<div class='p_selecionado'>3</div>"; } else { echo "<div class='p_uselecionado'>3</div>"; }?><div class='pt_texto'><?=REGISTO_LEFT_PASSO3?></div></li>
	  <li><? if($passo_num == 4) { echo "<div class='p_selecionado'>4</div>"; } else { echo "<div class='p_uselecionado'>4</div>"; } ?><div class='pt_texto'><?=REGISTO_LEFT_PASSO4?></div></li>
	 </ul>
	</div>
   </div>
   
   
    <div id="registo_area">
	<form method="post" onsubmit="return validaTodos()">
	 <div class="data_seccao">
	 <LABEL for="utilizador"><?=REGISTO_STEP1_UTILIZADOR?>: </LABEL>
      <INPUT type="text" id="utilizador" name="utilizador" onblur="validaUsername('utilizador', 'form_erro')">
      <span class="form_obrigatorio">*</span>
      <BR />
     
      <DIV CLASS="YN">
       <LABEL for="sexo"><?=REGISTO_STEP1_SEXO?>: </LABEL>
	   <INPUT type="radio" name="sexo" value="1" CHECKED><?=REGISTO_STEP1_SEX_M?>
	   <INPUT type="radio" name="sexo" value="0"><?=REGISTO_STEP1_SEX_F?>
	   <span class="form_obrigatorio">*</span>
	   <BR />
	  </DIV>
     <LABEL for="primeiro_nome"><?=REGISTO_STEP1_PNOME?>: </LABEL>
	  <INPUT type="text" id="primeiro_nome" name="primeiro_nome" onblur="validaPU('primeiro_nome', 'form_erro')">
	  <span class="form_obrigatorio">*</span>
	  <BR />
	 <LABEL for="ultimo_nome"><?=REGISTO_STEP1_UNOME?>: </LABEL>
	  <INPUT type="text" id="ultimo_nome" name="ultimo_nome" onblur="validaPU('ultimo_nome', 'form_erro')">
	  <span class="form_obrigatorio">*</span>
	  <BR />
	  
	  <LABEL for="DOBDay"><?=REGISTO_STEP1_DATANASCIMENTO?>: </LABEL>
	  <?=REGISTO_STEP1_DIA?>
	  <select name="DOBDay" style="vertical-align:middle;" tabindex="9">
	   <option value="1" selected="selected">1</option>
	   <option value='2'>2</option>
	   <option value='3'>3</option>
	   <option value='4'>4</option>
	   <option value='5'>5</option>
	   <option value='6'>6</option>
	   <option value='7'>7</option>
	   <option value='8'>8</option>
	   <option value='9'>9</option>
	   <option value='10'>10</option>
	   <option value='11'>11</option>
	   <option value='12'>12</option>
	   <option value='13'>13</option>
	   <option value='14'>14</option>
	   <option value='15'>15</option>
	   <option value='16'>16</option>
	   <option value='17'>17</option>
	   <option value='18'>18</option>
	   <option value='19'>19</option>
	   <option value='20'>20</option>
	   <option value='21'>21</option>
	   <option value='22'>22</option>
	   <option value='23'>23</option>
	   <option value='24'>24</option>
	   <option value='25'>25</option>
	   <option value='26'>26</option>
	   <option value='27'>27</option>
	   <option value='28'>28</option>
	   <option value='29'>29</option>
	   <option value='30'>30</option>
	   <option value='31'>31</option>
	  </select>
	  <?=REGISTO_STEP1_MES?>
	  <select name="DOBMonth" style="vertical-align:middle;" tabindex="10">
	   <option value="1" selected="selected"><?=REGISTO_STEP1_MES_JAN?></option>
	   <option value="2"><?=REGISTO_STEP1_MES_FEV?></option>
	   <option value="3"><?=REGISTO_STEP1_MES_MAR?></option>
	   <option value="4"><?=REGISTO_STEP1_MES_ABR?></option>
	   <option value="5"><?=REGISTO_STEP1_MES_MAI?></option>
	   <option value="6"><?=REGISTO_STEP1_MES_JUN?></option>
	   <option value="7"><?=REGISTO_STEP1_MES_JUL?></option>
	   <option value="8"><?=REGISTO_STEP1_MES_AGO?></option>
	   <option value="9"><?=REGISTO_STEP1_MES_SET?></option>
	   <option value="10"><?=REGISTO_STEP1_MES_OUT?></option>
	   <option value="11"><?=REGISTO_STEP1_MES_NOV?></option>
	   <option value="12"><?=REGISTO_STEP1_MES_DEZ?></option>
	  </select>
	  <?=REGISTO_STEP1_ANO?>
	  <select name="DOBYear" style="vertical-align: middle;" tabindex="11">
	   <option value='2006'>2006</option>
	   <option value='2005'>2005</option>
	   <option value='2004'>2004</option>
	   <option value='2003'>2003</option>
	   <option value='2002'>2002</option>
	   <option value='2001'>2001</option>
	   <option value='2000'>2000</option>
	   <option value='1999'>1999</option>
	   <option value='1998'>1998</option>
	   <option value='1997'>1997</option>
	   <option value='1996'>1996</option>
	   <option value='1995' selected="selected">1995</option>
	   <option value='1994'>1994</option>
	   <option value='1993'>1993</option>
	   <option value='1992'>1992</option>
	   <option value='1991'>1991</option>
	   <option value='1990'>1990</option>
	   <option value='1989'>1989</option>
	   <option value='1988'>1988</option>
	   <option value='1987'>1987</option>
	   <option value='1986'>1986</option>
	   <option value='1985'>1985</option>
	   <option value='1984'>1984</option>
	   <option value='1983'>1983</option>
	   <option value='1982'>1982</option>
	   <option value='1981'>1981</option>
	   <option value='1980'>1980</option>
	   <option value='1979'>1979</option>
	   <option value='1978'>1978</option>
	   <option value='1977'>1977</option>
	   <option value='1976'>1976</option>
	   <option value='1975'>1975</option>
	   <option value='1974'>1974</option>
	   <option value='1973'>1973</option>
	   <option value='1972'>1972</option>
	   <option value='1971'>1971</option>
	   <option value='1970'>1970</option>
	   <option value='1969'>1969</option>
	   <option value='1968'>1968</option>
	   <option value='1967'>1967</option>
	   <option value='1966'>1966</option>
	   <option value='1965'>1965</option>
	   <option value='1964'>1964</option>
	   <option value='1963'>1963</option>
	   <option value='1962'>1962</option>
	   <option value='1961'>1961</option>
	   <option value='1960'>1960</option>
	   <option value='1959'>1959</option>
	   <option value='1958'>1958</option>
	   <option value='1957'>1957</option>
	   <option value='1956'>1956</option>
	   <option value='1955'>1955</option>
	   <option value='1954'>1954</option>
	   <option value='1953'>1953</option>
	   <option value='1952'>1952</option>
	   <option value='1951'>1951</option>
	   <option value='1950'>1950</option>
	   <option value='1949'>1949</option>
	   <option value='1948'>1948</option>
	   <option value='1947'>1947</option>
	   <option value='1946'>1946</option>
	   <option value='1945'>1945</option>
	   <option value='1944'>1944</option>
	   <option value='1943'>1943</option>
	   <option value='1942'>1942</option>
	   <option value='1941'>1941</option>
	   <option value='1940'>1940</option>
	   <option value='1939'>1939</option>
	   <option value='1938'>1938</option>
	   <option value='1937'>1937</option>
	   <option value='1936'>1936</option>
	   <option value='1935'>1935</option>
	   <option value='1934'>1934</option>
	   <option value='1933'>1933</option>
	   <option value='1932'>1932</option>
	   <option value='1931'>1931</option>
	   <option value='1930'>1930</option>
	   <option value='1929'>1929</option>
	   <option value='1928'>1928</option>
	   <option value='1927'>1927</option>
	   <option value='1926'>1926</option>
	   <option value='1925'>1925</option>
	   <option value='1924'>1924</option>
	   <option value='1923'>1923</option>
	   <option value='1922'>1922</option>
	   <option value='1921'>1921</option>
	   <option value='1920'>1920</option>
	   <option value='1919'>1919</option>
	   <option value='1918'>1918</option>
	   <option value='1917'>1917</option>
	   <option value='1916'>1916</option>
	   <option value='1915'>1915</option>
	   <option value='1914'>1914</option>
	   <option value='1913'>1913</option>
	   <option value='1912'>1912</option>
	   <option value='1911'>1911</option>
	   <option value='1910'>1910</option>
	   <option value='1909'>1909</option>
	   <option value='1908'>1908</option>
	   <option value='1907'>1907</option>
	   <option value='1906'>1906</option>
	   <option value='1905'>1905</option>
	   <option value='1904'>1904</option>
	   <option value='1903'>1903</option>
	   <option value='1902'>1902</option>
	   <option value='1901'>1901</option>
	   <option value='1900'>1900</option>
	  </select>
	  <span class="form_obrigatorio">*</span>
	  <BR />
	  
	 <LABEL for="email"><?=REGISTO_STEP1_EMAIL?>: </LABEL>
	  <INPUT type="text" id="email" name="email" onblur="validaEmail('email', 'form_erro')">
	  <span class="form_obrigatorio">*</span>
	  <BR />
	 <LABEL for="contacto"><?=REGISTO_STEP1_CONTACTO?>: </LABEL>
	  <INPUT type="text" id="contacto" name="contacto" onblur="validaTelefone('contacto', 'form_erro')"><BR />
	 <LABEL for="fax"><?=REGISTO_STEP1_FAX?>: </LABEL>
	  <INPUT type="text" id="fax" name="fax" onblur="validaTelefone(this, 'form_erro')"><BR />
	 <LABEL for="pass"><?=REGISTO_STEP1_PASSWORD?>: </LABEL>
	  <INPUT type="password" id="pass" name="pass" onblur="validaPassword('pass', 'form_erro')" >
	  <span class="form_obrigatorio">*</span>
	  <BR />
	 <LABEL for="check_pass"><?=REGISTO_STEP1_CPASSWORD?>: </LABEL>
	  <INPUT type="password" id="check_pass" name="check_pass" onblur="PasswordCompara('check_pass', 'form_erro', 'pass')">
	  <span class="form_obrigatorio">*</span>
	  <BR />
	
	 <DIV CLASS="YN">
	  <LABEL for="newsletter"><?=REGISTO_STEP1_NEWSLETTER?>: </LABEL>
	  <INPUT type="radio" id="newsletter" name="newsletter" value="1" CHECKED><?=REGISTO_STEP1_NEWSL_S?>
	  <INPUT type="radio" id="newsletter" name="newsletter" value="0"><?=REGISTO_STEP1_NEWSL_N?><BR />
	 </DIV>
	 <LABEL for="nif"><?=REGISTO_STEP1_NIF?>: </LABEL>
	  <INPUT type="text" id="nif" name="nif" onblur="validaNIF('nif', 'form_erro') "><BR />
	 </div>
	 
	 <div id="info_seccao">
	  <div style="display: none; margin: auto; text-align: center; width: 300px; min-height: 20px; margin: auto;" id="form_erro">
	  </DIV>
	  <?
	if($_POST)
	{
		if(isset($mensagem))
		{
			echo $mensagem;
		}
	}	
	?>
	
	  <div class="btns" style="text-align: center">
	   <INPUT type="submit" value="<?=REGISTO_STEP1_CONTINUAR?>"><br /><br /> <INPUT type="reset" value="<?=REGISTO_STEP1_LIMPAR?>">
	  </div>
	 </div>
	 <INPUT type="hidden" value="2" name="step" id="step">
	</form>
	<?
	   echo REGISTO_CAMPOS_OBRIG . "<br />";
	?>
	
   </div>
   <A HREF="/">Voltar</A><br />
   
   
  </div>
  <div id="fundo_cinza_baixo">
  </div>